package com.heima.app;

import com.heima.Config.SpringConfig;
import com.heima.Mapper.UserMapper;
import com.heima.Pojo.User;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * 1. 导入依赖：mysql\druid\mybatis\mybatis-spring\spring-context\spring-jdbc
 * 2. 配置mybatis
 * 3. 核心配置类导入mybatis配置类
 * 4. 写一个pojo\mapper findById 方法
 * 5. 测试
 */

public class MybatisApp {
    public static void main(String[] args) {
        //1. 解析核心配置文件，获得容器
        AnnotationConfigApplicationContext acac =
                new AnnotationConfigApplicationContext(SpringConfig.class);

        //2. 获得mapper bean
        UserMapper userMapper = acac.getBean(UserMapper.class);

        //3. 查数据
        User byId = userMapper.findById(2);
        System.out.println(byId);
    }
}
